Skip to content

Implement Matplotlib image display with BGR/RGB comparison#2

Open
Michal-Fularz wants to merge 1 commit intomasterfrom
display-image-matplotlib-7117131935577827918
Open

Implement Matplotlib image display with BGR/RGB comparison#2
Michal-Fularz wants to merge 1 commit intomasterfrom
display-image-matplotlib-7117131935577827918

Conversation

@Michal-Fularz
Copy link
Copy Markdown
Member

Modified TODO 4 in image_processing_course/ipc_s01e01.py to display the color image using Matplotlib's imshow. The implementation now includes a side-by-side comparison of the image in its original BGR format and the converted RGB format to highlight the color space differences between OpenCV and Matplotlib.


PR created automatically by Jules for task 7117131935577827918 started by @Michal-Fularz

- Updated ipc_s01e01.py to show BGR and RGB versions in subplots.
- Added titles to plots for clarity.
- Kept OpenCV imshow for comparison.

Co-authored-by: Michal-Fularz <3768498+Michal-Fularz@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the ex_2 function to include a side-by-side comparison of BGR and RGB color spaces using Matplotlib. The feedback suggests enhancing the visualization by adjusting the figure size, removing axis ticks, and using plt.tight_layout() to prevent title overlap and improve overall readability.

Comment on lines +70 to +81
# Convert image to RGB for correct Matplotlib display
img_rgb = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB)

plt.figure()
plt.subplot(1, 2, 1)
plt.imshow(img_color)
plt.title('BGR (Incorrect)')

plt.subplot(1, 2, 2)
plt.imshow(img_rgb)
plt.title('RGB (Correct)')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The added code contains excessive blank lines that disrupt the readability of the function. Additionally, for side-by-side comparisons in Matplotlib, it is recommended to use plt.tight_layout() to ensure titles do not overlap and to specify a figsize for better visibility. Hiding the axis ticks with plt.xticks([]) and plt.yticks([]) is also a common practice for image display to focus on the content, as seen in other parts of this repository.

Suggested change
# Convert image to RGB for correct Matplotlib display
img_rgb = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB)
plt.figure()
plt.subplot(1, 2, 1)
plt.imshow(img_color)
plt.title('BGR (Incorrect)')
plt.subplot(1, 2, 2)
plt.imshow(img_rgb)
plt.title('RGB (Correct)')
# Convert image to RGB for correct Matplotlib display
img_rgb = cv2.cvtColor(img_color, cv2.COLOR_BGR2RGB)
plt.figure(figsize=(10, 5))
plt.subplot(1, 2, 1)
plt.imshow(img_color)
plt.title('BGR (Incorrect)')
plt.xticks([]), plt.yticks([])
plt.subplot(1, 2, 2)
plt.imshow(img_rgb)
plt.title('RGB (Correct)')
plt.xticks([]), plt.yticks([])
plt.tight_layout()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant